@extends('wechat.layouts.base')
@section("js_files")
    <script src="{{asset('dist/wechat/js/share_file.js')}}"></script>

    <script>
        //切换tab
        function showaa(param){
            if(param == 1){
                $("#btn1").siblings().removeClass("on");
                $("#btn1").addClass("on");
                $("#sevenstar").show();
                $("#renqiph").hide();
            }else{
                $("#btn2").siblings().removeClass("on");
                $("#btn2").addClass("on");
                $("#sevenstar").hide();
                $("#renqiph").show();
            }
        }
    </script>
@endsection
@section('content')
<div id="rank_head_tab"><img width="100%" src="{{asset('dist/wechat/img/rankh1.jpg')}}"></div>
    <div id="tabnav" class="clear">
        <a onclick="showaa(1)" id="btn1" class="btntab on" href="javascript:;">七星排行</a>
        <a onclick="showaa(2)" id="btn2" class="btntab" href="javascript:;">售楼部人气排行</a>
    </div>
    <div class="tabcontent">
        <ul id="sevenstar" class="ranklist">
        </ul>
        <div id="renqiph" class="ranklist"></div>
    </div>
    @endsection
@section('js')
    <script>
        $(function () {
            var host =window.location.host;
            $.ajax({
                url:'{{url('wechat/rank/stars')}}',
                dataType:"JSON",
                type:'GET',
                success:function(response){
                    if(response.success == true) {
                        var data = response.data;
                        console.log(data);
                        for (var i = 0; i < data.length; i++) {
                            var str = '<li class="clear" id= ' + data[i].id + '><a href="http://'+host+'/wechat/index/build/detailed?id='+data[i].id+'">' +
										'<div class="indexpic"><img src="' + data[i].attach.path + '"/></div>' +
										'<div class="bar"><div class="bar_t"><h4>' + data[i].name + '</h4></div><div class="bar_m"><button class="toupiao">刷脸投票</button><p>' + data[i].info + '</p></div><div class="bar_b"><p>七星指数:<span>' + data[i].star + '</span></p><p>楼盘人气:<span>' + data[i].count + '</span></p></div></div></a></li>';
							$("#sevenstar").append(str);
                        }
                        limitwd();
                    }
                }
            });
            $.ajax({
                url:'{{url('wechat/rank/count')}}',
                dataType:"JSON",
                type:'GET',
                success:function(response){
                    if(response.success == true){
                        var data = response.data;
                        console.log(data);
                        for(var i = 0; i<data.length;i++){
                            var str = '<li class="clear" id= '+data[i].id+'><a href="http://'+host+'/wechat/index/build/detailed?id='+data[i].id+'">' +
                                    '<div class="indexpic"><img src="'+ data[i].attach.path+'"/></div>'+
                                    '<div class="bar"><div class="bar_t"><h4>'+ data[i].name+'</h4></div><div class="bar_m"><button class="toupiao">刷脸投票</button><p>'+ data[i].info+'</p></div><div class="bar_b"><p>七星指数:<span>'+ data[i].star+'</span></p><p>楼盘人气:<span>'+ data[i].count+'</span></p></div></div></a></li>';
                            $("#renqiph").append(str);
                        }
                        limitwd()
                    }
                }
            });
        });
    </script>
    @endsection